const cloud = getApp().cloud;
const app = getApp();
Page({

  data: {
    pressWidth:540,
    second:10
  },

  onLoad(query) {

    //

    this.login();
    this.press();

  },

  // 登陆
  login(){
    my.authorize({
      scopes: 'scope.userInfo',
      success: (res) => {
        my.getAuthUserInfo({
          success: (userInfo) => {
            let body = {
              userNick:userInfo.nickName
            }
            cloud.function.invoke('client',body,'login').then(res => {
              console.log('load---登录',res);  
            })
          }
        });
      },
    });
  },



  press(){

      this.timert=setInterval(()=>{

        if( this.data.second > 0 ){

          this.setData({

            second: this.data.second - 1

          })

        }else{

          clearInterval(this.timert);

          //自动跳转到首页

        }

      },1000)
    
  },




  goIndex(){

    my.redirectTo({
      url: '../index/index'
    })

  }

});




